<!-- 医疗事业部活动系统附件编辑弹窗 -->
<template>
  <el-dialog
    :title="isUpdate?'修改医疗事业部活动系统附件':'添加医疗事业部活动系统附件'"
    :visible="visible"
    width="460px"
    :destroy-on-close="true"
    :lock-scroll="false"
    @update:visible="updateVisible">
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
      label-width="82px">
        <el-form-item label="父ID:" prop="parentId">
          <el-input-number
            :min="0"
            v-model="form.parentId"
            placeholder="请输入父ID"
            controls-position="right"
            class="ele-fluid ele-text-left"/>
        </el-form-item>
        <el-form-item
          label="对方经办人姓名 :"
          prop="name">
          <el-input
            :maxlength="20"
            v-model="form.dfjbrxm"
            placeholder="请输入对方经办人姓名 "
            clearable/>
        </el-form-item>
        <el-form-item
          label="对方经办人联系方式 :"
          prop="name">
          <el-input
            :maxlength="20"
            v-model="form.dflxfs"
            placeholder="请输入对方经办人联系方式 "
            clearable/>
        </el-form-item>
        <el-form-item
          label="对方当事人名称 :"
          prop="name">
          <el-input
            :maxlength="20"
            v-model="form.dfdsrmc"
            placeholder="请输入对方当事人名称 "
            clearable/>
        </el-form-item>
        <el-form-item
          label="年检营业执照 :"
          prop="name">
          <el-input
            :maxlength="20"
            v-model="form.njyyzz"
            placeholder="请输入年检营业执照 "
            clearable/>
        </el-form-item>
        <el-form-item
          label="对方经办人授权委托书 :"
          prop="name">
          <el-input
            :maxlength="20"
            v-model="form.dfsqwts"
            placeholder="请输入对方经办人授权委托书 "
            clearable/>
        </el-form-item>
        <el-form-item
          label="其他（食品/药品/特许经营许可证等） :"
          prop="name">
          <el-input
            :maxlength="20"
            v-model="form.qt"
            placeholder="请输入其他（食品/药品/特许经营许可证等） "
            clearable/>
        </el-form-item>
        <el-form-item
          label="契约锁签署动作 :"
          prop="name">
          <el-input
            :maxlength="20"
            v-model="form.qysqsdz"
            placeholder="请输入契约锁签署动作 "
            clearable/>
        </el-form-item>
        <el-form-item
          label="创建人:"
          prop="name">
          <el-input
            :maxlength="20"
            v-model="form.creator"
            placeholder="请输入创建人"
            clearable/>
        </el-form-item>
        <el-form-item
          label="修改人:"
          prop="name">
          <el-input
            :maxlength="20"
            v-model="form.modifier"
            placeholder="请输入修改人"
            clearable/>
        </el-form-item>
        <el-form-item label="修改时间:">
          <el-date-picker
            type="datetime"
            class="ele-fluid"
            v-model="form.modifyTime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择修改时间"/>
        </el-form-item>
        <el-form-item
          label=":"
          prop="name">
          <el-input
            :maxlength="20"
            v-model="form.status"
            placeholder="请输入"
            clearable/>
        </el-form-item>
        <el-form-item label="同步时间:">
          <el-date-picker
            type="datetime"
            class="ele-fluid"
            v-model="form.syncTime"
            value-format="yyyy-MM-dd HH:mm:ss"
            placeholder="请选择同步时间"/>
        </el-form-item>
    </el-form>
    <div slot="footer">
      <el-button @click="updateVisible(false)">取消</el-button>
      <el-button
        type="primary"
        @click="save"
        :loading="loading">保存
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'FormtableMain12083Dt1Edit',
  props: {
    // 弹窗是否打开
    visible: Boolean,
    // 修改回显的数据
    data: Object
  },
  data() {
    return {
      // 表单数据
      form: Object.assign({}, this.data),
      // 表单验证规则
      rules: {
        parentId: [
          {required: true, message: '请输入父ID', trigger: 'blur'}
        ],
        dfjbrxm: [
          {required: true, message: '请输入对方经办人姓名 ', trigger: 'blur'}
        ],
        dflxfs: [
          {required: true, message: '请输入对方经办人联系方式 ', trigger: 'blur'}
        ],
        dfdsrmc: [
          {required: true, message: '请输入对方当事人名称 ', trigger: 'blur'}
        ],
        njyyzz: [
          {required: true, message: '请输入年检营业执照 ', trigger: 'blur'}
        ],
        dfsqwts: [
          {required: true, message: '请输入对方经办人授权委托书 ', trigger: 'blur'}
        ],
        qt: [
          {required: true, message: '请输入其他（食品/药品/特许经营许可证等） ', trigger: 'blur'}
        ],
        qysqsdz: [
          {required: true, message: '请输入契约锁签署动作 ', trigger: 'blur'}
        ],
        creator: [
          {required: true, message: '请输入创建人', trigger: 'blur'}
        ],
        modifier: [
          {required: true, message: '请输入修改人', trigger: 'blur'}
        ],
        modifyTime: [
          {required: true, message: '请输入修改时间', trigger: 'blur'}
        ],
        status: [
          {required: true, message: '请输入', trigger: 'blur'}
        ],
        syncTime: [
          {required: true, message: '请输入同步时间', trigger: 'blur'}
        ],
      },
      // 提交状态
      loading: false,
      // 是否是修改
      isUpdate: false,
    };
  },
  watch: {
    data() {
      if (this.data) {
        this.form = Object.assign({}, this.data);
        this.isUpdate = true;
      } else {
        this.form = {};
        this.isUpdate = false;
      }
    }
  },
  methods: {
    /* 保存编辑 */
    save() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.loading = true;
          this.$http[this.isUpdate ? 'put' : 'post'](this.isUpdate ? '/formtablemain12083dt1/edit' : '/formtablemain12083dt1/add', this.form).then(res => {
            this.loading = false;
            if (res.data.code === 0) {
              this.$message.success(res.data.msg);
              if (!this.isUpdate) {
                this.form = {};
              }
              this.updateVisible(false);
              this.$emit('done');
            } else {
              this.$message.error(res.data.msg);
            }
          }).catch(e => {
            this.loading = false;
            this.$message.error(e.message);
          });
        } else {
          return false;
        }
      });
    },
    /* 更新visible */
    updateVisible(value) {
      this.$emit('update:visible', value);
    }
  }
}
</script>

<style scoped>
</style>
